<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery/jquery.min.js"></script>
    <style>
        .err{border: solid 1.6px red}
    </style>
</head>
<body>
<form  method="post" id="editForm">
    <input type="hidden" name="phone" value="" id="phone">
    <div class="form-field m-t-10">
        <input name="nickname" id="nickname" type="text" placeholder="您的昵称" data-required="required">
        <div class="err-tip"></div>
    </div>
    <div class="form-field">
        <input name="password" type="password" placeholder="您的密码" data-required="required">
        <div class="err-tip"></div>
    </div>
    <div class="form-field">
        <input name="rpassword" type="password" placeholder="确认密码" data-required="required">
        <div class="err-tip"></div>
    </div>

    <div class="form-field">
        <div class="clearfix">
            <a href="#" class="vcode-send sms-code-send">获取验证码</a>
            <input name="verifyCode" type="text" placeholder="短信验证码" autocomplete="off"class="vcode-input" data-required="required">
        </div>
        <div class="err-tip clearfix"></div>
    </div>
    <div class="submit-btn">
        <button type="submit">完成注册</button>
    </div>
</form>
<script>

    $("#editForm").submit(function () {
        if ($("[name=nickname]").val() == "") {
            $("[name=nickname]").addClass("err");
            $(".err-tip").html("用户名不能为空")
            setTimeout(function () {
                $("[name=nickname]").removeClass("err");
            },3000);
            return false;
        }
        return true;
    })

    // console.log($("#editForm"));
    // $("#editForm").submit(function () {
    //     var _this = this;
    //     var $inp = $("#editForm input");
    //     return false;
    // });

    // console.log($("#editForm [data-required=required]"));

   // required("#editForm")
   //
   //  function required(ele) {
   //      var arr =[];
   //      $(ele+" [data-required=required]").each(function (index, ele) {
   //          // console.log($(ele));
   //          $(ele).blur(function () {
   //              $(this).val()=="" ? arr.push(false) : arr.push(true);
   //              console.log(arr);
   //          })
   //      })
   //      return arr;
   //  }
</script>
</body>
</html>